import axios from 'axios'
import store from '../store.js'
const $require = axios.create({
	timeout: 5000,
	baseURL: "https://easy-mock.com/mock/5d65e4b905d30d7155d6a7e0/api"
})

//请求拦截
$require.interceptors.request.use(
	function(config){
		let token = store.state.token;
		if(token){
			config.headers.Authorize = token;
		}
		return config;
	},
	function(error){
		return Promise.reject(error);
	}
)
//响应拦截
$require.interceptors.response.use(
	function(response){
		return response;
	},
	function(error){
		return Promise.reject(error);
	}
)

export default $require;